<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>

<html>
<head>
	<link rel="stylesheet" href="${ctx}/static/css/jquery-ui.min.css" />
	<title>用户反馈</title>
	<script src="${ctx}/static/js/jquery-ui.min.js"></script>
    <script>
     
      $(function () {
    	  $('.popover-hide').popover('hide');
    	  
    	  
    	  $('.show_msg').click(function(e) {
    		  $("#div_tel").html("预留联系方式：" + $(this).children().eq(0).text());
        	  $("#tt_msg").val($(this).children().eq(1).text());
        	  
        	  var dialog = $("#dialog-msg").removeClass('hide').dialog({
                  modal: true,
                  height: 350,width:500 ,
                  title: "反馈内容",
                  title_html: true,
                  buttons: [
                      {
                          text: "取消",
                          "class": "btn btn-xs",
                          click: function () {
                              $(this).dialog("close");
                          }
                      }
                  ]
              });
    		  
    	    });
    	  
    	});
      
      function reviewForm(id){
    	  $("#div_reviews").html("反馈记录：<br><br>");
    	  $("#tt_review").val("");
    	  
    	  var dialog = $("#dialog-reviewForm").removeClass('hide').dialog({
              modal: true,
              height: 450,width:500 ,
              title: "反馈处理",
              title_html: true,
              buttons: [
                  {
                      text: "提交",
                      "class": "btn btn-primary btn-xs",
                      click: function () {
                    	 var tempThis = $(this);
                    	//判断不为空且小于50个汉字
                    	if($("#tt_review").val().length > 0 && $("#tt_review").val().length < 51) {
                    		$.ajax({
                    			type:'POST',
                    			url:'${ctx}/feedback/review/',
                    			dataType:"json", 
                    			data:{
              	            	 'feedbackId':id ,     
              	        		 'review':$("#tt_review").val() },
                    			success:function(data) {
                    				alert(data.resMsg);
                    				if(data.resCode == 1) {
                    					tempThis.dialog("close");
                    					window.location.reload();
                    				}
                    			}
                      		});
                    	} else {
                    		alert("处理意见不能为空且需要小于50汉字");
                    	} 
                      }
                  },
                  {
                      text: "取消",
                      "class": "btn btn-xs",
                      click: function () {
                          $(this).dialog("close");
                      }
                  }
              ]
          });
    	  
  		$.ajax({
  			type:'get',
  			url:'${ctx}/feedback/reviewForm/' + id,
  			dataType:"json", 
  			success:function(data) {  
  				if(data.resCode == 1) {
              		var reuslt = data.data;
              		var str = "";
              		$.each(reuslt, function(i) {
              			str += reuslt[i].createTime + "&nbsp;&nbsp;" + reuslt[i].reviewer.name + "<br>" + reuslt[i].review + "<br><br>";
   	        		 });
              		$("#div_reviews").html("反馈记录：<br><br>" + str);
  				} else {
  					$("#div_reviews").html("反馈记录：<br><br>获取反馈记录失败，刷新重试或联系管理员");
              	}
  		     }
  		});	  
  	}
   </script>
</head>

<body>	
	
	<div class="main-content-inner">
		<!-- #section:basics/content.breadcrumbs -->
		<div class="breadcrumbs" id="breadcrumbs">
			<script type="text/javascript">
				try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
			</script>
	
			<ul class="breadcrumb">
				<li>
					<i class="ace-icon fa fa-home home-icon"></i>
					<a href="${ctx}/welcome">主页</a>
				</li>
				<li class="active">用户反馈</li>
			</ul><!-- /.breadcrumb -->
	
			<!-- #section:basics/content.searchbox -->
			<div class="nav-search" id="nav-search">
				<form class="form-search" action="${ctx}/feedback/list" method="GET">
<!-- 					<span class="input-icon"> -->
<%-- 						<input type="text" autocomplete="off" name="search_LIKE_user.name" placeholder="姓名 ..." class="nav-search-input" id="nav-search-input" autocomplete="off" value="${param['search_LIKE_user.name']}" /> --%>
<!-- 						<i class="ace-icon fa fa-search nav-search-icon" onclick="$('.form-search').submit();"></i> -->
<!-- 					</span> -->
					<span class="input-icon">
						<input type="text" autocomplete="off" name="search_EQ_mobile" placeholder="电话 ..." class="nav-search-input" id="nav-search-input" autocomplete="off" value="${param['search_EQ_mobile']}" />
						<i class="ace-icon fa fa-search nav-search-icon" onclick="$('.form-search').submit();"></i>
					</span>
					<!-- 
					<span class="input-icon">
						<select class="nav-search-input" id="feedback_deltag" name="search_EQ_deltag" data-placeholder="请选择状态">					
							<option value="0" <c:if test="${param.search_EQ_deltag eq '0' }">selected="selected"</c:if>>有用</option>
							<option value="1" <c:if test="${param.search_EQ_deltag eq '1' }">selected="selected"</c:if>>无用</option>
						</select>
					</span>
					 -->
					<input type="button" value="搜索" onclick = "$('.form-search').submit();" />
				</form>
			</div><!-- /.nav-search -->
	
			<!-- /section:basics/content.searchbox -->
		</div>	
		<!-- /section:basics/content.breadcrumbs -->
		
		<div class="page-content">
			
			<c:if test="${not empty message}">
				<div id="message" class="alert alert-success"><button data-dismiss="alert" class="close">×</button>${message}</div>
			</c:if>	
			
			<div class="page-header">
				<h1>
					反馈
					<small>
						<i class="ace-icon fa fa-angle-double-right"></i>
						信息列表
					</small>
				</h1>
				
			</div><!-- /.page-header -->			
			
			<div class="row">
				<div class="col-xs-12">
					<!-- PAGE CONTENT BEGINS -->
					
					<table id="sample-table-1" class="table table-striped table-bordered table-hover">
						<thead>
							<tr>
								<th class="center">
									<label class="position-relative">
										<input type="checkbox" id="id-toggle-all" class="ace" />
										<span class="lbl"></span>
									</label>
								</th>
								<th>发布时间</th>
								<th>提交用户ID</th>
								<th>反馈内容</th>
								<th>最新处理结果</th>
								<th>最新处理时间</th>
								<th>最新处理人</th>
								<th>操作</th>
							</tr>
						</thead>

						<tbody>
							<c:forEach items="${feedbacks.content}" var="feedback">
							<tr>
								<td class="center">
									<label class="position-relative">
										<input type="checkbox" class="ace" />
										<span class="lbl"></span>
									</label>
								</td>
								
								<td>
									<fmt:formatDate value="${feedback.createDate}" pattern="yyyy-MM-dd  HH:mm:ss" />
								</td>	
								<td>
										${feedback.userId}
								</td>
								<td class="show_msg" >
									<span style="display: none;">${feedback.mobile}</span>
									<span style="display: none;">${feedback.message}</span>
									<c:choose>
										<c:when test="${fn:length(feedback.message)>10 }">
											${fn:substring(feedback.message,0,10)}…
										</c:when>
										<c:otherwise>
											${feedback.message}
										</c:otherwise>
									</c:choose>
								</td>	
								<td>
									<c:choose>
										<c:when test="${fn:length(feedback.lastReview)>10 }">
											${fn:substring(feedback.lastReview,0,10)}…
										</c:when>
										<c:otherwise>
											${feedback.lastReview}
										</c:otherwise>
									</c:choose>
								</td>
								<td>
									<fmt:formatDate value="${feedback.lastReviewTime}" pattern="yyyy-MM-dd  HH:mm:ss" />
								</td>
								<td>
									${feedback.lastReviewerName}
								</td>
								<!-- 
								<td>
									<c:choose>
										<c:when test="${feedback.deltag eq '0' }">
											有用
										</c:when>
										<c:otherwise>
											无用
										</c:otherwise>
									</c:choose>
								</td>
								 -->
								
								<td align="left">
										<a class="btn btn-xs btn-danger" href="javaScript:reviewForm(${feedback.id});">
											处理
										</a>
										<!-- 
										<c:if test="${feedback.deltag eq '0' }">
										<shiro:hasPermission name="business:feedback:delete">
											<a class="btn btn-xs btn-danger" href="${ctx}/feedback/delete/${feedback.id}">
												无用信息
											</a>
										</shiro:hasPermission>
										</c:if>
										 -->
								</td>									
							</tr>
							</c:forEach>
						</tbody>
					</table>
				</div>
			</div>
			
			<div id="dialog-reviewForm" class="hide">
                <div class="form-group">
                    <div class="col-sm-9">
                    	<textarea id="tt_review" placeholder="请输入处理结果内容，最多50个汉字" rows="7" cols="60" maxlength="50"></textarea>
                    </div>
					<div id="div_reviews" class="col-sm-9" style="margin-top: 10px"></div>
                </div>
                <p>
                </p>
            </div>
            
            <div id="dialog-msg" class="hide">
                <div class="form-group">
                    <div class="col-sm-9">
                    	<textarea id="tt_msg" rows="7" cols="60"></textarea>
                    </div>
					<div id="div_tel" class="col-sm-9" style="margin-top: 10px">
					</div>
                </div>
                <p>
                </p>
            </div>
			
			<tags:pagination page="${feedbacks}" paginationSize="5"/>
		</div><!-- /.page-content -->
	</div>
</body>
</html>
<!-- inline scripts related to this page -->	